﻿@inject FwProject.Shop.Views.WebRootUrl WebRootUrl
@{
    ViewBag.Title = "优惠券发放列表";
}
@model Guid
@section styles{
    <link href="~/static/css/client.css" type="text/css" rel="stylesheet" />
    <link href="~/static/css/system.css" type="text/css" rel="stylesheet" />
    <link href="~/static/css/contract.css" type="text/css" rel="stylesheet" />
}
<style>
    a {
        text-decoration: none;
    }

    .hidden {
        display: none;
    }
</style>
<div class="layui-fluid layui-content">
    <div class="layui-title layui-clear layui-row">
        <h2 class="layui-col-md10 layui-col-sm9 layui-col-xs7">@ViewBag.Title</h2>
        <div class="layui-col-md2 layui-col-sm3 layui-col-xs5 layui-nav-item">

        </div>
    </div>
    <div class="layui-data layui-table-container" style="margin-top: 15px;">
        <table class="layui-hide layui-table" id="layui-table" lay-filter="table"></table>
    </div>
</div>
<div id="Layer_ajax" class="deploy-plus"></div>
<script type="text/html" id="titleTpl">
    <a href="javascript:top.NewTab(1054,'订单明细-{{d.orderNumber}}','/Order/OrderHandle?orderNumber={{d.orderNumber}}')" class="layui-table-link">{{d.orderNumber}}</a>
</script>
@section scripts{
    <script src="~/static/js/jquery.ztree.core.js" type="text/javascript"></script>
    <script src="~/static/js/jquery.ztree.excheck.js" type="text/javascript"></script>
    <script src="~/static/js/jquery.ztree.exedit.js" type="text/javascript"></script>
    <script src="~/js/main.js"></script>
    <script type="text/javascript">
        var layer,form, table;
        layui.use(['form', 'layedit', 'laydate',  'table', 'layer'], function () {
            var /*form = layui.form*/
                layedit = layui.layedit
                , laydate = layui.laydate;

            layer = layui.layer;
            form = layui.form;
            table = layui.table;

            table.render({
                elem: "#layui-table",
                url: '/Coupon/GetShopUserCouponData',
                where: { id:"@Model" },
                cellMinWidth: 26,
                height: 'full-150',
                cols: [[
                    //{ type: 'checkbox' },
                    { field: 'orderNumber', title: '订单号',templet: '#titleTpl'},
                    {
                        field: 'creationTime', title: '创建时间', templet: function (d) {
                            var creationTime = new Date(d.creationTime);
                            return 'creationTime', top.dateFtt("yyyy-MM-dd", creationTime);
                        }
                    },
                    {
                        field: 'useStatus', title: '使用状态', templet: function (d) {
                            if (d.useStatus=='0') {
                                return 'useStatus', '未使用';
                            } else if (d.useStatus == '1') {
                                return 'useStatus', '已使用';
                            } else if (d.useStatus == '2') {
                                return 'useStatus', '删除优惠券';
                            }
                        }
                    },
                    { field: 'userName', title: '使用会员' },
                    {
                        field: 'useBeginTime', title: '开始使用时间', templet: function (d) {
                            var useBeginTime = new Date(d.shopCoupon.useBeginTime);
                            return 'useBeginTime', top.dateFtt("yyyy-MM-dd", useBeginTime);
                        }
                    },
                    {
                        field: 'useEndTime', title: '结束使用时间', templet: function (d) {
                            var useEndTime = new Date(d.shopCoupon.useEndTime);
                            return 'useEndTime', top.dateFtt("yyyy-MM-dd", useEndTime);
                        }
                    },
                ]],
                id: "idTest",
                page: true,
            });

        });


        $(document).ready(function () {

        });
        var lock = false;//锁作为全局变量
        function LoadNewOpen(url) {
            if (lock) {
                return false;
            } else {
                lock = true;
            }
            $("#Layer_ajax").load(url, function (responseTxt, statusTxt, xhr) {
                if (statusTxt == "error") {
                    top.layer.msg('页面加载失败！', {
                        icon: 2,
                        time: 2000
                    });
                    return false;
                }
                form.render('select')
                var uploadInst = upload.render({
                    elem: '#b_piclogo' //绑定元素
                    , url: '/Brands/UpLoadBarand' //上传接口
                    , done: function (res) {
                        if (res.success) {
                            var img = "@WebRootUrl.WebImageRootUrl()/uploads/temp/brand/";
                            $('#BrandLogo').val(res.result)
                            $('#piclogoImg').attr("src", img + res.result)
                        }
                    }
                    , error: function () {
                        //请求异常回调
                    }
                });
                $.validator.unobtrusive.parse(this);
                var height = $("#Layer_ajax").height();
                layer.open({
                    type: 1,
                    shadeClose: true,
                    title: false,
                    closeBtn: 0,
                    scrollbar: false,
                    content: $("#Layer_ajax"),
                    area: ["600px", height],
                    success: function (layero, index) {
                        //锁关闭
                        lock = false;
                    },
                    end: function () {
                        $("#Layer_ajax").empty();
                    }
                })
            })
        }

        function LayerOpen(title, url) {
            var open = layer.open({
                type: 2,
                title: title,
                shadeClose: true,
                shade: false,
                maxmin: true, //开启最大化最小化按钮
                area: ['600px', '450px'],
                content: url,
                success: function (layero, index) {
                    var body = layer.getChildFrame('body', index)//确定两个页面的父子关系
                },
                end: function () {
                    //销毁后重新加载
                    table.reload('idTest', {
                        page: {
                            curr: 1 //重新从第 1 页开始
                        }
                    })
                }
            });
        }
    </script>
}